<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
	<title></title>
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
	<script src="js/jquery.min.js"></script>
	<script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
	<script src="https://cdn.staticfile.org/vue-router/2.7.0/vue-router.min.js"></script>
	<script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>
	<style type="text/css">
	#info{
		top: 100px;
		left: 100px;
		font-size: 20px;
	}
	#head{
		position: relative;
		top: 50px;
		border-radius: 100%;
		width: 40%;
		height: 40%;
		background-repeat: no-repeat;
		margin-top: 20px;
	}
	#img{
		position: relative;
		margin-top: -45px;
		margin-left: 100px;
		width: 100px;
		height: 120px;
		opacity:0; 
	}
	.button{
		margin-top: 60px;
		margin-left: 80px;
		width: 100px;
		height: 50px;
		background-image: url(images/submit.png);
		
	}
	</style>
</head>
<body>			
			<div id="app">
				<div class="row" >
					<div class="col-sm-6" id="info">
						<div>
							<p>用户名:{{user.account}}</p>
							<p>性别:{{user.gender}}</p>
							<p>身份证号:{{user.number}}</p>
							<p>电话:{{user.phone}}</p>
							<p>邮箱:{{user.email}}</p>
							<p>注册时间:{{user.regtime}}</p>
						</div>
					</div>
				  	<div class="col-sm-6" >
				  		
						<img v-bind:src="user.head" id="head" /><br/>
						<button class="button">修改头像</button>
						<input type="file" name="headImg" id="img">						
					</div>
				</div>
			</div>
				
<script type="text/javascript">
	new Vue({
		el:"#app",
		data:{
			user:''
		},
		//页面加载完后触发
		mounted(){
			axios.get("user/find").then(res => {
				if(res.data!=null){
					this.user=res.data;
					
				}else{
					alert("系统繁忙");
				}
				
			})
		},
		methods:{
			
		
			
		}
	});
	
	//头像上传
	$("#img").change(function(){
	//创建FormData对象 用于文件上传
	var fd = new FormData();
	//得到要上传的文件
	var file = $("#img")[0].files[0];
	//将文件放入到formdata中
	fd.append("headImg",file);
	//发送文件
	$.ajax({
		url:"user/upload",
		type:"post",
		data:fd,
		//是否要序列化，文件本身是二进制数据，不需要序列化
		processData:false,
		//提交的数据格式,false表示不指定格式，将数据当做普通文件处理
		contentType:false,
		success:function(res){
			//$("#headImg").prop("src",res);
			location.reload()
		}
	});
});
</script>
</body>
</html>
